<?php $this->load->view('admin/adhead.html'); ?>

<?php $this->load->view('admin/adsider.html'); ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">

    <!-- Main content -->
    <section class="content">

      <div class="box box-primary">
            <div class="box-header">
              <h3 class="box-title">分类列表</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">
              <table class="table table-condensed">
                <tbody><tr>
                  <th style="width: 50px; text-align:center;">序号</th>
                  <th style="width:30%;">分类名</th>
                  <th>文章数</th>
                  <th >比例</th>
				   <th style="width:20%;">操作</th>
                </tr>
				<?php $i=1;$k=0;$bar=array('danger','yellow','primary','success');$bg=array('red','yellow','light-blue','green'); ?>
                <?php foreach($cate as $item): ?>
				<tr>
                  <td align="center"><?php echo $i;$i++; ?></td>
                  <td><?=$item->name?></td>			  
                  <td>
                    <div class="progress progress-xs">
                      <div class="progress-bar progress-bar-<?php echo $bar[$k]; ?>" style="width: <?=$item->num.'%'?>"></div>
                    </div>
                  </td>
                  <td><span class="badge bg-<?php echo $bg[$k]; ?>"><?=$item->num."%"?></span></td>
				  <td><a href="#" data-id="<?=$item->id?>" class="modalrw btn btn-info btn-xs">重命名</a> <a href="#" data-id="<?=$item->id?>" class="modaldel btn btn-warning btn-xs">删除</a></td>
                </tr><?php  $k++;if($k==count($bg)){$k=0;}?>
				<?php endforeach; ?>

              </tbody></table>
            </div>
            <!-- /.box-body -->
          </div>
		  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newcate">新增一个分类</button>
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

<?php $this->load->view('admin/adfooter.html'); ?>

<!----删除分类------>
<div class="modal fade modal-warning" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <form method="post" action="<?php echo site_url('article/deletecate');?>">
	<div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel1">提醒</h4>
            </div>
            <div class="modal-body">您确定要删除该文章？该分类下的文章也将被删除！</div><input type="hidden" name="id" id="delid" />
            <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-outline">确定删除</button>
            </div>
        </div><!-- /.modal-content -->
    </form></div><!-- /.modal -->
</div>

<!----重命名分类------>
<div class="modal fade modal-info" id="rewitename" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
	<form method="post" action="<?php echo site_url('article/renamecate');?>">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">重命名分类</h4>
            </div>
            <div class="modal-body"><input class="form-control" type="text" name="name" placeholder="输入分类名"></div>
            <div class="modal-footer"><input type="hidden" name="id" id="cateid" />
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-outline">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </form></div><!-- /.modal -->
</div>

<!----新增分类------>
<div class="modal fade modal-success" id="newcate" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
	<form method="post" action="<?php echo site_url('article/addcate');?>">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel3">新增一个分类</h4>
            </div>
            <div class="modal-body"><input class="form-control" type="text" name="name" placeholder="输入分类名"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-outline">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </form></div><!-- /.modal -->
</div>
<script type="text/javascript">
<!--
//重命名分类
$('.modalrw').on('click',function(e){
	$('#cateid').val($(this).attr("data-id"));
	$('#rewitename').modal('show');
	return false;
})

//删除分类
$('.modaldel').on('click',function(e){
	$('#delid').val($(this).attr("data-id"));
	$('#myModal').modal('show');
	return false;
})
//-->
</script>